import { LinkedList } from '../src/LinkedList/LinkedList'
// const { LinkedList } = require('../src/LinkedList/LinkedList')

const linkedList = new LinkedList()
linkedList.push(12)
linkedList.push(13)
linkedList.push(14)
linkedList.push(15)
linkedList.push(16)
linkedList.push(17)
linkedList.push(18)
linkedList.push(19)
// 移除索引为2的元素
linkedList.removeAt(2)
// 获取0号元素
console.log(linkedList.getElementAt(0))
// 查找19在链表中的位置
console.log(linkedList.indexOf(19))
// 在2号位置添加22元素
linkedList.insert(22, 2)
// 获取链表中的所有元素
console.log(linkedList.toString())

console.log('===========')

function mergeLinked(list1: Array<number>, list2: Array<number>) {
  let linkedList1 = new LinkedList()
  let linkedList2 = new LinkedList()
  list1.forEach(item => linkedList1.push(item))
  list2.forEach(item => linkedList2.push(item))

  // 合并
  let last = linkedList1.getElementAt(linkedList1.size() - 1)
  last.next = linkedList2.getHead()
  console.log(linkedList1.getElementAt(linkedList1.size() - 1))
}

mergeLinked([5, 9, 10, 90, 190, 2184738], [11, 23, 2, 4, 57, 129, 0])
